from tqdm.auto import tqdm

with open("nugine_solutions/data/STCharacters.txt") as src:
    with open("nugine_solutions/data/s2t_chars.txt", "w") as dst:
        for line in tqdm(src.readlines(), total=3980):
            items = line.strip().split()
            dst.write(f"{items[0]}:{' '.join(items[1:])}\n")

with open("nugine_solutions/data/TSCharacters.txt") as src:
    with open("nugine_solutions/data/t2s_chars.txt", "w") as dst:
        for line in tqdm(src.readlines(), total=4113):
            items = line.strip().split()
            dst.write(f"{items[0]}:{' '.join(items[1:])}\n")

with open("nugine_solutions/data/STPhrases.txt") as src:
    with open("nugine_solutions/data/s2t_phrases.txt", "w") as dst:
        for line in tqdm(src.readlines(), total=49119):
            items = line.strip().split()
            dst.write(f"{items[0]}:{' '.join(items[1:])}\n")
        patches = [["面条", "麵條"], ["子丑寅卯", "子丑寅卯"]]
        for patch in patches:
            dst.write(f"{patch[0]}:{patch[1]}\n")

with open("nugine_solutions/data/TSPhrases.txt") as src:
    with open("nugine_solutions/data/t2s_phrases.txt", "w") as dst:
        for line in tqdm(src.readlines(), total=278):
            items = line.strip().split()
            dst.write(f"{items[0]}:{' '.join(items[1:])}\n")
